<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>专业编辑</title>
	<%@include file="../common/common.jsp" %>
    <script type="text/javascript" src="js/jquery.form.js"></script>
  </head>
  <body>
    <form id="frm" class="definewidth m20">
		<input type="hidden" name="action" value="${param.action }" />
		<input type="hidden" name="id" value="${param.id }" />
	    <table class="table table-bordered table-hover definewidth m10">
	        <tr>
	            <td width="14%" class="tableleft">专业名称</td>
	            <td><input type="text" name="name" id="name" value="${info.name}"/></td>
	        </tr>
	        <tr>
	        	<td>所属学院</td>
	        	<td>
	        		<select name="collegeId" id="collegeId">
			    		<option value="">请选择学院</option>
			    		<c:forEach items="${listCollege }" var="college">
			    			<option value="${college.id }" <c:if test="${college.id eq info.college_id }"> selected</c:if>>${college.name }</option>
			    		</c:forEach>
			    	</select>
	        	</td>
	        </tr>
	        <tr>
	            <td class="tableleft"></td>
	            <td>
	                <button type="button" onclick="save()" class="btn btn-primary" type="button">保存</button>				 &nbsp;&nbsp;
	                <button type="button" class="btn" id="btnBack">返回</button>
	            </td>
	        </tr>
	    </table>
	</form>
  </body>
  <script type="text/javascript">
  	function save(){
  		var n=$("#name").val();
  		if(jQuery.trim(n)==''){
  			alert("请输入专业名词")
  			$("#name").focus()
  			return;
  		}
  		var collegeId=$("#collegeId").val();
  		if(collegeId==''){
  			alert("请选择学院")
  			return;
  		}
		var str=$('#frm').formSerialize();
    	$.post("professional/save.do",str,function (a,b){
    		if(b=='success'){
    			var msg=a.msg;
    			alert(msg)
    			if(msg=='保存成功'){
    				window.location.href="<%=basePath%>professional/query.do";
    			}
    		}
    	});
    }
    $(function (){
    	$("#btnBack").click(function (){
    		window.history.back(-1);
    	});
    })
  </script>
</html>
